package com.nbsaas.boot.storage.rest.resource;

import com.nbsaas.boot.storage.api.apis.FileApi;
import com.nbsaas.boot.storage.data.entity.File;
import com.nbsaas.boot.storage.api.domain.request.FileRequest;
import com.nbsaas.boot.storage.api.domain.response.FileResponse;
import com.nbsaas.boot.storage.api.domain.simple.FileSimple;
import com.nbsaas.boot.storage.rest.convert.FileSimpleConvert;
import com.nbsaas.boot.storage.rest.convert.FileEntityConvert;
import com.nbsaas.boot.storage.rest.convert.FileResponseConvert;
import com.nbsaas.boot.storage.data.repository.FileRepository;

import java.io.Serializable;
import com.nbsaas.boot.jpa.data.core.BaseResource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;

import java.util.function.Function;
/**
*   业务接口实现
*/
@Transactional
@Service
public class FileResource extends BaseResource<File,FileResponse, FileSimple, FileRequest>  implements FileApi {

    @Resource
    private FileRepository fileRepository;

    @Override
    public JpaRepositoryImplementation<File, Serializable> getJpaRepository() {
        return fileRepository;
    }

    @Override
    public Function<File, FileSimple> getConvertSimple() {
        return new FileSimpleConvert();
    }

    @Override
    public Function<FileRequest, File> getConvertForm() {
        return new FileEntityConvert();
    }

    @Override
    public Function<File, FileResponse> getConvertResponse() {
        return new FileResponseConvert();
    }




}


